home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / Snippets / Files / PBDTGetAppl / Source / PrintLoop.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-07  |  1.9 KB  |  107 lines  |  [TEXT/KAHL]

  1. /*
  2.     9-30-92  • Brigham Stevens
  3.     --------------------------
  4.  
  5.     Bare minimum printing loop.
  6.     Hacked out of Tech Note #161
  7.     Calls DrawImage inside Drawing.c to image the printed page
  8. */
  9.  
  10.  
  11. #include "Printing.h"
  12.  
  13. pascal void PrintIdleProc()
  14. {
  15.     short    err;
  16.     
  17.     err = PrError();
  18.  
  19.     /*    we could spin the cursor here if we want */
  20.         
  21.     if(err) {
  22.         InitCursor();        /* set to arrow */
  23.         ErrMsgCode("\pI'm in the printing idle proc.",err);
  24.     }
  25. }
  26.  
  27. void PrintWindow()
  28. /*
  29.     This will call the drawing code set up in
  30.     Drawing.c for the printing GrafPort
  31.     when there is an error, the code gotoos the
  32.     exit so the printer driver will be closed.
  33. */
  34. {
  35.     THPrint        tpr;
  36.     TPPrPort    printPort;
  37.     short        err;
  38.     TPrStatus    tprStat;
  39.     
  40.     tpr = NewHandle(sizeof(TPrint));
  41.     if(!tpr) {
  42.         ErrMsgCode("\pAllocating TPrint failed.",0);
  43.         return;  /* driver not open yet */
  44.     }
  45.     
  46.     PrOpen();
  47.     if(err = PrError()) {
  48.         ErrMsgCode("\p PrOpen failed.",err);
  49.         goto exit;
  50.     }
  51.     
  52.     if(!PrStlDialog(tpr))    goto exit;
  53.     if(err = PrError()) {
  54.         ErrMsgCode("\p PrStlDialog failed.",err);
  55.         goto exit;
  56.     }
  57.     
  58.     if(!PrJobDialog(tpr))    goto exit;
  59.     if(err = PrError()) {
  60.         ErrMsgCode("\p PrJobDialog failed.",err);
  61.         goto exit;
  62.     }
  63.     
  64.     SetCursor(*GetCursor(watchCursor));
  65.     (**tpr).prJob.pIdleProc = PrintIdleProc;
  66.     
  67.     printPort = PrOpenDoc(tpr, nil, nil);
  68.     if(err = PrError()) {
  69.         ErrMsgCode("\p PrOpenDoc failed.",err);
  70.         goto exit;
  71.     }
  72.     
  73.     PrOpenPage(printPort, nil);
  74.     if(err = PrError()) {
  75.         ErrMsgCode("\p PrOpenPage failed.",err);
  76.         goto exit;
  77.     }
  78.     
  79.     DrawImage(printPort);
  80.     
  81.     PrClosePage(printPort);
  82.     if(err = PrError()) {
  83.         ErrMsgCode("\p PrClosePage failed.",err);
  84.         goto exit;
  85.     }
  86.  
  87.     PrCloseDoc(printPort);
  88.     if(err = PrError()) {
  89.         ErrMsgCode("\p PrCloseDoc failed.",err);
  90.         goto exit;
  91.     }
  92.     
  93.     if( ((**tpr).prJob.bJDocLoop == bSpoolLoop))
  94.         PrPicFile( tpr, nil, nil, nil, &tprStat);
  95.  
  96.     if(err = PrError()) {
  97.         ErrMsgCode("\p PrPicFile failed.",err);
  98.         goto exit;
  99.     }
  100.     
  101. exit:
  102.     PrClose();
  103.     if(err = PrError())
  104.         ErrMsgCode("\p PrClose failed.",err);
  105.     
  106.     InitCursor();
  107. }